#ifndef __GLESDepthBuffer_H__
#define __GLESDepthBuffer_H__


#include "U2GLESPrerequest.h"
#include "U2GLESHardwarePixelBuffer.h"
#include "U2GLESRenderSystem.h"
#include "U2DepthBuffer.h"


U2EG_NAMESPACE_BEGIN


/** @copydoc U2DepthBuffer

	OpenGL supports 2 different methods: FBO & Copy.
	Each one has it's own limitations. Non-FBO methods are solved using "dummy" DepthBuffers.
	That is, a U2DepthBuffer pointer is attached to the U2RenderTarget (for the sake of consistency)
	but it doesn't actually contain a Depth surface/renderbuffer (mDepthBuffer & mStencilBuffer are
	null pointers all the time) Those dummy DepthBuffers are identified thanks to their GL context.
	Note that FBOs don't allow sharing with the main window's depth buffer. Therefore even
	when FBO is enabled, a dummy U2DepthBuffer is still used to manage the windows.
*/
class _U2GLESShare U2GLESDepthBuffer : public U2DepthBuffer
{
public:
	U2GLESDepthBuffer( u2uint16 poolId, GLESRenderSystem *renderSystem, U2GLESContext *creatorContext,
					GLESRenderBuffer *depth, GLESRenderBuffer *stencil,
					u2uint32 width, u2uint32 height, u2uint32 fsaa, u2uint32 multiSampleQuality,
					bool isManual );
	~U2GLESDepthBuffer();

	/// @copydoc U2DepthBuffer::isCompatible
	virtual bool isCompatible( U2RenderTarget *renderTarget ) const;

	U2GLESContext* getGLContext() const { return mCreatorContext; }
	GLESRenderBuffer* getDepthBuffer() const  { return mDepthBuffer; }
	GLESRenderBuffer* getStencilBuffer() const { return mStencilBuffer; }

protected:
	u2uint32					mMultiSampleQuality;
	U2GLESContext				*mCreatorContext;
	GLESRenderBuffer			*mDepthBuffer;
	GLESRenderBuffer			*mStencilBuffer;
	GLESRenderSystem			*mRenderSystem;
};


U2EG_NAMESPACE_END


#endif
